package main

import "fmt"

// first channel来作为函数参数,即是一个单向的channel
func first(c chan string) {
	c <- "买菜\n"
	close(c)
}

func second(c1 chan string, c2 chan string) {
	r := <-c1
	c2 <- r + "买肉\n"
	close(c2)
}

func Cook(c chan string) {
	r := <-c
	fmt.Println(r + "已经准备好，吃顿好的了!")
}

func main() {
	ch1 := make(chan string)
	ch2 := make(chan string)

	go first(ch1)
	go second(ch1, ch2)
	Cook(ch2)
	fmt.Println("洗碗")
}
